#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{

	int n;
	cin >> n;
	string temps;
	vector<string> a;
	for (int i = 0; i < n; i++)
	{
		cin >> temps;
		a.push_back(temps);
	}

	string max = "-1";
	int index = 0;
	for (int i = 0; i < a.size(); i++)
	{
		if(max.size() < a[i].size() || (max.size() == a[i].size() && max < a[i]))
		{
			max = a[i];
			index = i;
		}
	}
	cout << index + 1 << endl;
	cout << a[index] << endl;
	
	return 0;
}